<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <h1>列表</h1>
  <table border="1">
    <tr>
      <th>id</th>
      <th>名称</th>
      <th>价格</th>
      <th>库存</th>
      <th>操作</th>
    </tr>
    <tr v-for="p in arr">
      <td>{{p.id}}</td>
      <td>{{p.title}}</td>
      <td>{{p.price}}</td>
      <td>{{p.num}}</td>
      <td><a href="javascript:void(0)" @click="delete1(p.id)">删除</a>
      <a :href="'/update.html?id='+p.id">修改</a>
      </td>
    </tr>
  </table>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
   <script src=" https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
     <script>
       let v=new Vue({
         el:"body>div",
         data:{
           arr:{id:"",title:"",price:"",num:""}
         },
         methods:{
           delete1(id){
             if(confirm("删除?")) {
               axios.get("/delete?id="+id).then(function (r) {
                 location.reload();
               })
             }
           }
         },
         created:function (){
           axios.get("/select").then(function (r) {
             v.arr=r.data
           })
         }
       })

     </script>
</body>
</html>